package com.booking.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.booking.bean.Food;
import com.booking.bean.Food_PageBean;
import com.booking.bean.PageBean;
import com.booking.bean.Seller;
import com.booking.service.FoodQueryService;
import com.booking.service.SellerQueryService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

@Controller
public class FoodAction extends ActionSupport  implements ModelDriven<Food>{
	
	//模型驱动使用的对象
	private Food food = new Food();
	@Override
	public Food getModel() {
		return food;
	}
	
	@Autowired
	private FoodQueryService foodQueryService;
	
	private Integer pageNo = 1;
	private Integer sId;
	
	public void setPageNo(Integer pageNo) {
		this.pageNo = pageNo;
	}

	public void setsId(Integer sId) {
		this.sId = sId;
	}

	public String  findAll(){
//            String pageNo = request.getParameter("pageNo");
            if (pageNo == null) {
                pageNo = 1;
            }
            Food_PageBean pageBean = foodQueryService.findByPage(Integer.valueOf(pageNo), 12,sId);
//            request.setAttribute("page", page);
//            List<Seller> seller = page.getList();
//            request.setAttribute("sellers", seller);
           
           if(pageBean != null){
    		ActionContext.getContext().getValueStack().push(pageBean);
//			ActionContext.getContext().getSession().put("loginUser",);

    		return "success";
           }
           return null;
	}

}
